package com.ee.chat.api.task;

import com.ee.chat.api.common.CommonService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @Author Shane
 * @Date 2019/8/1 23:33
 */
@Component
@Async
public class TopTask {
    private Logger log = LoggerFactory.getLogger(TopTask.class);

    @Resource
    CommonService commonService;

    /**
     * 统计神豪榜数据
     * 凌晨3点统计
     * @Author Shane
     * @Date 2019/8/1 23:45
     * @param
     * @return
     */
    @Scheduled(cron = "0 0 3 * * ?")
    public void statUserCoinSaleTop() throws Exception{
        if(!commonService.getIpStatus()){
            return;
        }

        //统计消费金币数据
        commonService.handleUserCoinConsume();

        log.info("神豪榜数据已刷新");
    }

    /**
     * 统计魅力榜数据
     * 凌晨3点统计
     * @Author Shane
     * @Date 2019/8/1 23:45
     * @param
     * @return
     */
    @Scheduled(cron = "0 0 3 * * ?")
    public void statCharmTop() throws Exception{
        if(!commonService.getIpStatus()){
            return;
        }

        //统计主播积分数据
        commonService.handleHostCredit();

        log.info("魅力榜数据已刷新");
    }

    /**
     * 统计神聊榜数据
     * 凌晨3点统计
     * @Author Shane
     * @Date 2019/8/1 23:45
     * @param
     * @return
     */
    @Scheduled(cron = "0 0 3 * * ?")
    public void statCallTimeTop() throws Exception{
        if(!commonService.getIpStatus()){
            return;
        }

        //统计主播通话时长/次数的数据
        commonService.handleHostCallTime();

        log.info("神聊榜数据已刷新");
    }

    /**
     * 统计勤奋榜数据
     * 凌晨3点统计
     * @Author Shane
     * @Date 2019/8/1 23:45
     * @param
     * @return
     */
    @Scheduled(cron = "0 0 3 * * ?")
    public void statHWTop() throws Exception{
        if(!commonService.getIpStatus()){
            return;
        }

        //统计主播通话时长/次数的数据
        commonService.handleHostHW();

        log.info("勤奋榜数据已刷新");
    }

}
